Skip to content

[9.0.1] Improve Jupyter Notebook REST API [ch61633] (Sourcery refactored)#127

Closed
sourcery-ai[bot] wants to merge 11 commits into
release/9.0from
sourcery/task/dss-91-improve-jupyter-api
Closed

[9.0.1] Improve Jupyter Notebook REST API [ch61633] (Sourcery refactored)#127
sourcery-ai[bot] wants to merge 11 commits into
release/9.0from
sourcery/task/dss-91-improve-jupyter-api

Conversation

@sourcery-ai

@sourcery-ai sourcery-ai Bot commented Mar 22, 2021

Copy link
Copy Markdown

Pull Request #124 refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the task/dss-91-improve-jupyter-api branch, then run:

git fetch origin sourcery/task/dss-91-improve-jupyter-api
git merge --ff-only FETCH_HEAD
git reset HEAD^

@sourcery-ai sourcery-ai Bot requested a review from pbailly March 22, 2021 17:04
@cstenac cstenac changed the title [9.0.1] Improve Jupyter Notebook REST API [ch61633] (Sourcery refactored) [TEST - IGNORE] [9.0.1] Improve Jupyter Notebook REST API [ch61633] (Sourcery refactored) Mar 22, 2021
@sourcery-ai sourcery-ai Bot changed the title [TEST - IGNORE] [9.0.1] Improve Jupyter Notebook REST API [ch61633] (Sourcery refactored) [9.0.1] Improve Jupyter Notebook REST API [ch61633] (Sourcery refactored) Mar 23, 2021
@sourcery-ai sourcery-ai Bot force-pushed the sourcery/task/dss-91-improve-jupyter-api branch from 494f84d to 4cf4702 Compare March 23, 2021 13:37
@sourcery-ai sourcery-ai Bot force-pushed the sourcery/task/dss-91-improve-jupyter-api branch from 4cf4702 to 15e0e57 Compare March 23, 2021 14:43
Comment thread dataikuapi/dssclient.py
Comment on lines -594 to +599
definition = {}
definition['name'] = cluster_name
definition['type'] = cluster_type
definition['params'] = params if params is not None else {}
definition = {
'name': cluster_name,
'type': cluster_type,
'params': params if params is not None else {},
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSClient.create_cluster refactored with the following changes:

Comment thread dataikuapi/dssclient.py
Comment on lines -708 to +710
if isinstance(v, str) or isinstance(v, unicode):
if isinstance(v, (str, unicode)):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSClient.make_entry refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -196 to +198
ref = self.client._perform_json("POST", "/projects/%s/duplicate/" % self.project_key, body = obj)
return ref
return self.client._perform_json(
"POST", "/projects/%s/duplicate/" % self.project_key, body=obj
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.duplicate refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -266 to +269
if as_type == "listitems" or as_type == "listitem":
if as_type in ["listitems", "listitem"]:
return [DSSDatasetListItem(self.client, item) for item in items]
elif as_type == "objects" or as_type == "object":
elif as_type in ["objects", "object"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_datasets refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -406 to +409
if as_type == "listitems" or as_type == "listitem":
if as_type in ["listitems", "listitem"]:
return [DSSStreamingEndpointListItem(self.client, item) for item in items]
elif as_type == "objects" or as_type == "object":
elif as_type in ["objects", "object"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_streaming_endpoints refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -718 to +719
if as_type == "objects" or as_type == "object":
if as_type in ["objects", "object"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_model_evaluation_stores refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -924 to +927
if not "standard" in obj:
if "standard" not in obj:
raise ValueError("Missing 'standard' key in argument")
if not "local" in obj:
if "local" not in obj:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.set_variables refactored with the following changes:

  • Simplify logical expression using De Morgan identities (de-morgan)

Comment thread dataikuapi/dss/project.py
Comment on lines -1143 to +1146
if as_type == "listitems" or as_type == "listitem":
if as_type in ["listitems", "listitem"]:
return [DSSRecipeListItem(self.client, item) for item in items]
elif as_type == "objects" or as_type == "object":
elif as_type in ["objects", "object"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.list_recipes refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -1231 to +1232
elif type == "prepare" or type == "shaker":
elif type in ["prepare", "shaker"]:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProject.new_recipe refactored with the following changes:

Comment thread dataikuapi/dss/project.py
Comment on lines -1590 to +1593
already_exists = False
for rule in found_eo["rules"]:
if rule["targetProject"] == target_project:
already_exists = True
break
already_exists = any(
rule["targetProject"] == target_project for rule in found_eo["rules"]
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DSSProjectSettings.add_exposed_object refactored with the following changes:

  • Use any() instead of for loop (use-any)

@sourcery-ai

sourcery-ai Bot commented Mar 23, 2021

Copy link
Copy Markdown
Author

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.39%.

Quality metrics Before After Change
Complexity 2.16 ⭐ 1.97 ⭐ -0.19 👍
Method Length 29.77 ⭐ 29.56 ⭐ -0.21 👍
Working memory 8.30 🙂 8.27 🙂 -0.03 👍
Quality 80.23% 80.62% 0.39% 👍
Other metrics Before After Change
Lines 2374 2375 1
Changed files Quality Before Quality After Quality Change
dataikuapi/dssclient.py 81.22% ⭐ 81.53% ⭐ 0.31% 👍
dataikuapi/dss/project.py 79.64% ⭐ 80.08% ⭐ 0.44% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
dataikuapi/dss/project.py DSSProject.new_recipe 16 🙂 178 😞 28 ⛔ 30.13% 😞 Try splitting into smaller methods. Extract out complex expressions
dataikuapi/dssclient.py DSSClient.create_meaning 5 ⭐ 116 🙂 14 😞 55.31% 🙂 Extract out complex expressions
dataikuapi/dss/project.py DSSProject.duplicate 2 ⭐ 70 🙂 18 ⛔ 60.50% 🙂 Extract out complex expressions
dataikuapi/dssclient.py DSSClient.sql_query 1 ⭐ 60 ⭐ 20 ⛔ 61.62% 🙂 Extract out complex expressions
dataikuapi/dssclient.py DSSClient._perform_http 5 ⭐ 94 🙂 11 😞 62.98% 🙂 Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

Base automatically changed from task/dss-91-improve-jupyter-api to release/9.0 March 23, 2021 15:05
@sourcery-ai sourcery-ai Bot closed this Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant